package com.mb.app.task;

import com.mb.app.domain.TbMemberInfo;
import com.mb.common.service.NotifysService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;


/**
 * 异步消息通知
 */
@Component
@Slf4j
public class AsyncNotifyTask {

    @Autowired
    private NotifysService notifyService;

    /**
     * 异步消息通知
     */
    @Async("taskExecutor")
    public void Notify(TbMemberInfo memberInfo){

        log.info("Notify start ........");
        try {
            Map<String,Object> msgMap = new HashMap<String, Object>();
            msgMap.put("phone",memberInfo.getPhone());
            msgMap.put("name",memberInfo.getMemberName());
            notifyService.sendNotify(msgMap);
        } catch (Exception e) {
            log.error("Notify",e);
        }
        log.info("Notify end  .......");
    }

}
